package com.arsProfundis
package services

import cc.spray._
import cc.spray.http.MediaTypes._

import com.arsProfundis.model._

trait SmartDreamerService extends Directives {

  val service = {
    path("") {
      get {
        respondWithMediaType(`text/html`) {
          _.complete(com.arsProfundis.html.main("Anonymous").body)
        }
      } ~
      put {
        _.complete("Received PUT request for order")
      } ~
      post {
        formFields('story) { story =>

        val stories = List(
          RelevantStory(Story(Person("1","Bob"),"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tempor tincidunt adipiscing. Donec leo tellus, auctor eu ornare vitae, aliquet et quam."), 5),
          RelevantStory(Story(Person("2","Lary"),"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tempor tincidunt adipiscing. Donec leo tellus, auctor eu ornare vitae, aliquet et quam."), 2),
          RelevantStory(Story(Person("3","John"),"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse tempor tincidunt adipiscing. Donec leo tellus, auctor eu ornare vitae, aliquet et quam."), 3)
            )

          respondWithMediaType(`text/html`) {
            _.complete(com.arsProfundis.html.stories(stories).body)
          }
        }
      }
    }
  }
}
